import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { StoreVO, StoreForm, StoreQuery } from '@/api/business/store/types';

/**
 * 查询诊所管理列表
 * @param query
 * @returns {*}
 */

export const listStore = (query?: StoreQuery): AxiosPromise<StoreVO[]> => {
  return request({
    url: '/business/store/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询诊所管理详细
 * @param id
 */
export const getStore = (id: string | number): AxiosPromise<StoreVO> => {
  return request({
    url: '/business/store/' + id,
    method: 'get'
  });
};

/**
 * 新增诊所管理
 * @param data
 */
export const addStore = (data: StoreForm) => {
  return request({
    url: '/business/store',
    method: 'post',
    data: data
  });
};

/**
 * 修改诊所管理
 * @param data
 */
export const updateStore = (data: StoreForm) => {
  return request({
    url: '/business/store',
    method: 'put',
    data: data
  });
};

/**
 * 删除诊所管理
 * @param id
 */
export const delStore = (id: string | number | Array<string | number>) => {
  return request({
    url: '/business/store/' + id,
    method: 'delete'
  });
};

/**
 * 用户密码重置
 * @param userId 用户ID
 * @param password 密码
 */
export const resetUserPwd = (userId: string | number, password: string) => {
  const data = {
    userId,
    password
  };
  return request({
    url: '/business/store/resetPwd',
    method: 'put',
    headers: {
      isEncrypt: true,
      repeatSubmit: false
    },
    data: data
  });
};

/**
 * 充值-次数
 * @param storeId
 * @param balance
 * @returns
 */
export const recharge = (storeId: string | number, balance: string | number) => {
  const data = {
    storeId,
    balance
  };
  return request({
    url: '/business/store/recharge',
    method: 'put',
    headers: {
      isEncrypt: true,
      repeatSubmit: true
    },
    data: data
  });
};

/**
 * 充值-金额
 * @param storeId
 * @param amount
 * @returns
 */
export const rechargeAmount = (storeId: string | number, amount: string | number) => {
  const data = {
    storeId,
    amount
  };
  return request({
    url: '/business/store/rechargeAmount',
    method: 'put',
    headers: {
      isEncrypt: true,
      repeatSubmit: true
    },
    data: data
  });
};

export const reactivate = (id: string | number | Array<string | number>) => {
  return request({
    url: '/business/store/reactivate/' + id,
    method: 'put'
  });
};
